package theone.ui;

import java.util.ArrayList;
import java.util.List;

import org.newdawn.slick.Graphics;

public class UiCompositeComponent extends UiComponent {
	
	//Collection of child graphics.
    private List<UiComponent> childGraphics = new ArrayList<UiComponent>();
 
    //Adds the graphic to the composition.
    public void add(UiComponent graphic) {
        childGraphics.add(graphic);
    }
 
    //Removes the graphic from the composition.
    public void remove(UiComponent graphic) {
        childGraphics.remove(graphic);
    }

	@Override
	public void draw(Graphics g, int offsetX, int offsetY) {
		for (UiComponent graphic : childGraphics) {
            graphic.draw(g, offsetX + getX(), offsetY + getY());
        }
	}

	@Override
	public void setHover(boolean hover) {
		super.setHover(hover);
		for (UiComponent graphic : childGraphics) {
            graphic.setHover(hover);
        }
	}

	@Override
	public void setHoverSensitive(boolean hoverSensitive) {
		for (UiComponent graphic : childGraphics) {
            graphic.setHoverSensitive(hoverSensitive);
        }
	}

}
